package com.biz.hunter.dao;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.biz.hunter.dbutil.BaseDAO;

@Repository
public class StatisticDAO {
	static Logger logger = LoggerFactory.getLogger(EmployeeDAO.class);
	
	private static final String SQL_GET_HY_COUNT = "SELECT COUNT(*) FROM tb_employee WHERE domainId=?";
	
	private static final String SQL_GET_HS_DOMAIN_COUNT = "SELECT COUNT(*) FROM tb_employee a, tb_person b, tb_company c WHERE a.personid = b.id AND b.companyid = c.id AND c.domain = ? AND a.intenttime = ?";
	
	private static final String SQL_GET_HS_COMPANY_COUNT = "select COUNT(*) from tb_employee a, tb_jobtitle b WHERE a.intentTime = ? and a.expectJob = b.id and b.postype=? and (a.expectCompany1 = ? OR a.expectCompany2 = ? OR a.expectCompany3 = ?)";
	
	private static final String SQL_GET_QWZW_COMPANY_COUNT = "select COUNT(*) from tb_employee a WHERE a.expectJob = ? and (a.expectCompany1 = ? OR a.expectCompany2 = ? OR a.expectCompany3 = ?)";
	
	private static final String SQL_GET_XRGS_DOMAIN_COUNT = "select COUNT(*) FROM tb_employee a, tb_person b, tb_company c where a.personid=b.id and b.companyid=c.id and c.domain =?";
	
	private static final String SQL_GET_XRGS_COMPANY_COUNT = "select COUNT(*) FROM tb_employee a, tb_person b where a.personid=b.id and b.companyid=?";
	
	private static final String SQL_GET_XRGS_JOB_COUNT = "select COUNT(*) from tb_employee a, tb_person b, tb_jobtitle c where a.personid=b.id and b.roleId=c.id and c.postype=?";
	
	public Long getCountOfDomain(int domainid) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_HY_COUNT, domainid);
	}
	
	public Long getCountOfIntentTimeOfDomain(int domainid, int intenttime) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_HS_DOMAIN_COUNT, domainid, intenttime);
	}
	
	public Long getCountOfIntentTimeOfJobTypeOfCompany(int intenttime, int jobtype, int companyid) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_HS_COMPANY_COUNT, intenttime, jobtype, companyid, companyid, companyid);
	}

	public Long getCountOfJobOfCompany(long jobid, int companyid) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_QWZW_COMPANY_COUNT, jobid, companyid, companyid, companyid);
	}
	
	public Long getCountOfSubDomain(int domainid) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_XRGS_DOMAIN_COUNT, domainid);
	}

	public Long getCountOfCompany(long companyid) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_XRGS_COMPANY_COUNT, companyid);
	}

	public Long getCountOfJobtype(int postype) {
		return (Long) BaseDAO.queryOneRowOneCol(SQL_GET_XRGS_JOB_COUNT, postype);
	}

}
